package com.xtsoft.platform.base.system.domain;

/*
*    上海信拓信息技术有限公司  
*    Copyright (C) ShangHai XinTuo Software Inc.
*/

import com.fasterxml.jackson.annotation.JsonIgnore;
import com.xtsoft.core.entity.GenericEntity;
import lombok.Data;
import org.hibernate.annotations.GenericGenerator;

import jakarta.persistence.*;
import java.util.ArrayList;
import java.util.List;

/**
 * SysResource Base Java Bean, base class for the model, mapped directly to database table
 * 
 * Avoid changing this file if not necessary, will be overwritten. 
 *
 * 指系统URL（链接）、Method（方法）、菜单
 */
@Entity
@Table(name = "sys_resource")
@Data
//@Cache(usage = CacheConcurrencyStrategy.NONSTRICT_READ_WRITE)
public class SysResource extends GenericEntity {


	@Id
	@GeneratedValue(generator = "system-uuid")
	@GenericGenerator(name = "system-uuid", strategy = "uuid")
	@Column(name="resUniqueId",nullable=false,length=32)
    private String resUniqueId;

	/**
	 *  资源ID 
	 */
	@Column(name="resourceId",nullable=true ,length=32)
    private String resourceId;	

	/**
	*   资源类型
	*/
	@Column(name="resourceType",nullable=false, length=10 )
	private Integer resourceType;


	/**
	*   资源名称
	*/
	@Column(name="resourceName",nullable=false, length=128 )
	private String resourceName;


	/**
	*   资源昵称
	*/
	@Column(name="resourceNick",nullable=true, length=128 )
	private String resourceNick;


	/**
	*   资源URL
	*/
	@Column(name="resourceUrl",nullable=true, length=255 )
	private String resourceUrl;


	/**
	*   上级资源标识
	*/
	@Column(name="preResourceId",nullable=true, length=32 )
	private String preResourceId;


	/**
	*   图标标识
	*/
	@Column(name="iconClsId",nullable=true, length=32 )
	private String iconClsId;


	/**
	*   是否公共资源
	*/
	@Column(name="isPublic",nullable=true, length=10 )
	private Integer isPublic;


	/**
	*   是否信息范围控制
	*/
	@Column(name="isInfControl",nullable=true, length=10 )
	private Integer isInfControl;


	/**
	*   序号
	*/
	@Column(name="serialNo",nullable=false, length=10 )
	private Integer serialNo;


	/**
	*   是否桌面图标
	*/
	@Column(name="isDesktop",nullable=false, length=10 )
	private Integer isDesktop;


	/**
	*   是否快速启动栏
	*/
	@Column(name="isQuickLaunch",nullable=false, length=10 )
	private Integer isQuickLaunch;


	/**
	*   资源方法
	*/
	@Column(name="attachMethod",nullable=true, length=128 )
	private String attachMethod;


	/**
	*   提示
	*/
	@Column(name="toolTip",nullable=true, length=128 )
	private String toolTip;


	/**
	*   文件路径
	*/
	@Column(name="filePath",nullable=true, length=128 )
	private String filePath;


	/**
	*   二级分类
	*/
	@Column(name="secType",nullable=true, length=10 )
	private Integer secType;


	/**
	*   小图标
	*/
	@Column(name="iconClsQuick",nullable=true, length=32 )
	private String iconClsQuick;
	
	/**
	*   颜色
	*/
	@Column(name="buttonClr",nullable=true, length=64 )
	private String buttonClr;

	/**
	*   状态    值  0 禁用  1 启用
	*/
	@Column(name="state",nullable=false, length=10 )
	private Integer state;
	
	/**
	*   说明
	*/
	@Column(name="descript",nullable=true, length=255 )
	private String descript;
	
	/**
	 * 构建复选框树形结构
	 * 是否选中
	 */
	@Transient
	private Boolean checked;
	
	@Transient
	private String isChecked;
	
	@Transient
	public List<SysResource> list=new ArrayList<SysResource>();
	
	
    
	@OneToMany(mappedBy = "sysResource", cascade = CascadeType.ALL, fetch = FetchType.LAZY)
	@JsonIgnore
	private List<ResourceRole> resourceRoles = new ArrayList();

	public void setChildren(List<SysResource> children) {
		this.list = children;
	}
	public List<SysResource> getChildren() {
		return this.list;
	}    


	
	@Override  
	public boolean equals(Object obj) {  
	    if (obj instanceof SysResource) {  
	        return this.resUniqueId.equals(((SysResource) obj).getResUniqueId());  
	    }  
	    return false;  
	}  	

	@Override  
	public int hashCode() {  
	    return this.resUniqueId.hashCode();  
	} 
}
